import type { VbenFormSchema } from '#/adapter/form';
import type { VxeGridPropTypes } from '#/adapter/vxe-table';

import { $t } from '#/locales';

/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      component: 'Input',
      fieldName: 'id',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'accountId',
      label: $t('views.mp.tag.accountId'),
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'name',
      label: $t('views.mp.tag.name'),
      component: 'Input',
      rules: 'required',
      componentProps: {
        placeholder: $t('views.mp.tag.namePlaceholder'),
      },
    },
  ];
}

/** 表格列配置 */
export function useGridColumns(): VxeGridPropTypes.Columns {
  return [
    {
      title: $t('views.common.id'),
      field: 'id',
    },
    {
      title: $t('views.mp.tag.name'),
      field: 'name',
    },
    {
      title: $t('views.mp.tag.count'),
      field: 'count',
    },
    {
      title: $t('common.createTime'),
      field: 'createTime',
      formatter: 'formatDateTime',
    },
    {
      title: $t('common.action'),
      width: 140,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}
